<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>查看已完成任务</title>
</head>
<body>
<div th:fragment="main" id="checkProcessed" class="checkProcessed">
    <link rel="stylesheet" th:href="@{/assets/viewer/viewer.css}">
    <link rel="stylesheet" th:href="@{/assets/jquery.eeyellow.Timeline/jquery.eeyellow.Timeline.css}">
    <link rel="stylesheet" th:href="@{/css/assignmentGroup/checkProcessed.css}">
    <div class="pending_content">
        <!-- 导航栏 -->
        <div class="title clearfix">
            <ol class="breadcrumb title-content pull-left">
                <li><a href="#qualitycontrol-assignmentGroup-processed">任务管理</a></li>
                <li>查看已完成任务</li>
            </ol>
            <a class="btn btn-primary goback" href="#qualitycontrol-assignmentGroup-processed">
                <span>«</span>
                返回
            </a>
        </div>
        <!-- 内容 -->
        <div class="contents">
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active">
                    <a href="#basic" aria-controls="basic" role="tab" data-toggle="tab">基本信息</a>
                </li>
                <li role="presentation">
                    <a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">流程信息</a>
                </li>
            </ul>
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="basic">
                    <div id="basicInformation" class="basic-information">
                        <!-- 基本信息 -->
                    </div>
                    <div class="ibox">
                        <div class="ibox-title examine">
                            <span></span>
                            <h5>任务图片</h5>
                        </div>
                        <div class="pending-pictures" id="pendingPictures">
                            <div class="carousel slide" id="carousel3">
                                <div class="review-images" id="reviewImages">
                                    <ul id="reviewImagesList" class="clearfix">
                                        <!-- 审核图片 -->
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div role="tabpanel" class="tab-pane" id="profile">
                    <div class="task-process">
                        <div class="taskprocess-info" id="taskProcessInfo">
                            <div class="VivaTimeline" id="processedVivaTimeline">
                                <!-- 流程信息 -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 基本业务数据模板 -->
    <script type="text/template" id="basicInformationTpl">
        <table>
            {{if processRule != null}}
            <tbody>
            <tr>
                <td>
                    <p class="heading"><span>设备编号</span>&nbsp;: </p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.deviceId}}" readonly>
                </td>
                <td colspan="2">
                    <p class="heading"><span>设备类型</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{deviceTypeName}}" readonly>
                </td>
                <td colspan="3">
                    <p class="heading"><span>设备位置</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{deviceAddrs}}" readonly>
                </td>
            </tr>
            <tr>
                <td>
                    <p class="heading"><span>经纬度</span>&nbsp;:</p>
                    <input name="" class="" type="text"
                           value="{{subTaskBusinessData.longitude}} / {{subTaskBusinessData.latitude}}" readonly>
                </td>
                {{if processRule.additionalBusinessId == 4}}
                <td>
                    <p class="heading"><span>获取方式</span>&nbsp;:</p>
                    {{if subTaskBusinessData.acquisitionMode}}
                    <input name="" class="" type="text" value="蓝牙" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="WIFI" readonly>
                    {{/if}}
                </td>
                <td>
                    <span class="heading">RSRP&nbsp;:</span>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.rsrp}}" readonly>
                </td>
                <td>
                    <span class="heading">CELLID&nbsp;:</span>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.cellid}}" readonly>
                </td>
                <td>
                    <span class="heading">SINR&nbsp;:</span>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.sinr}}" readonly>
                </td>
                {{else if processRule.additionalBusinessId == 5}}
                <td>
                    <p class="heading"><span>获取方式</span>&nbsp;:</p>
                    {{if subTaskBusinessData.acquisitionMode}}
                    <input name="" class="" type="text" value="蓝牙" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="WIFI" readonly>
                    {{/if}}
                </td>
                <td>
                    <span class="heading">RSRP&nbsp;:</span>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.rsrp}}" readonly>
                </td>
                <td>
                    <span class="heading">CELLID&nbsp;:</span>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.cellid}}" readonly>
                </td>
                <td>
                    <span class="heading">SINR&nbsp;:</span>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.sinr}}" readonly>
                </td>
                {{/if}}
            </tr>
            <tr>
                {{if processRule.additionalBusinessId == 1}}
                <td>
                    <p class="heading"><span>具备安装</span>&nbsp;:</p>
                    {{if subTaskBusinessData.install}}
                    <input name="" class="" type="text" value="是" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="否" readonly>
                    {{/if}}
                </td>
                <td colspan="3">
                    <p class="heading"><span>原因</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.isInstallDesc}}" readonly>
                </td>
                {{else if processRule.additionalBusinessId == 4}}
                <td>
                    <p class="heading"><span>具备安装</span>&nbsp;:</p>
                    {{if subTaskBusinessData.install}}
                    <input name="" class="" type="text" value="是" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="否" readonly>
                    {{/if}}
                </td>
                <td colspan="3">
                    <p class="heading"><span>原因</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.isInstallDesc}}" readonly>
                </td>
                {{else if processRule.additionalBusinessId == 7}}
                <td>
                    <p class="heading"><span>具备安装</span>&nbsp;:</p>
                    {{if subTaskBusinessData.install}}
                    <input name="" class="" type="text" value="是" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="否" readonly>
                    {{/if}}
                </td>
                <td colspan="3">
                    <p class="heading"><span>原因</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.isInstallDesc}}" readonly>
                </td>
                {{/if}}
            </tr>
            <tr>
                {{if processRule.additionalBusinessId == 3}}
                <td colspan="2">
                    <p class="heading"><span>故障原因</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.faultReason}}" readonly>
                </td>
                <td colspan="2">
                    <p class="heading"><span>故障描述</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.faultDesc}}" readonly>
                </td>
                <td>
                    <p class="heading"><span>是否恢复</span>&nbsp;:</p>
                    {{if subTaskBusinessData.recove}}
                    <input name="" class="" type="text" value="是" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="否" readonly>
                    {{/if}}
                </td>
                {{else if processRule.additionalBusinessId == 6}}
                <td colspan="2">
                    <p class="heading"><span>故障原因</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.faultReason}}" readonly>
                </td>
                <td colspan="2">
                    <p class="heading"><span>故障描述</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.faultDesc}}" readonly>
                </td>
                <td>
                    <p class="heading"><span>是否恢复</span>&nbsp;:</p>
                    {{if subTaskBusinessData.recove}}
                    <input name="" class="" type="text" value="是" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="否" readonly>
                    {{/if}}
                </td>
                {{else if processRule.additionalBusinessId == 9}}
                <td colspan="2">
                    <p class="heading"><span>故障原因</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.faultReason}}" readonly>
                </td>
                <td colspan="2">
                    <p class="heading"><span>故障描述</span>&nbsp;:</p>
                    <input name="" class="" type="text" value="{{subTaskBusinessData.faultDesc}}" readonly>
                </td>
                <td>
                    <p class="heading"><span>是否恢复</span>&nbsp;:</p>
                    {{if subTaskBusinessData.recove}}
                    <input name="" class="" type="text" value="是" readonly>
                    {{else}}
                    <input name="" class="" type="text" value="否" readonly>
                    {{/if}}
                </td>
                {{/if}}
            </tr>
            <tr>
                <td colspan="9">
                    {{if subTaskProcessInfoList.length > 1}}
                        {{if subTaskState == 1}}
                        <p class="heading"><span>备注</span>&nbsp;:</p>
                        <div class="remarks">{{subTaskProcessInfoList[1].description}}</div>
                        {{else if subTaskState == 2}}
                        <p class="heading"><span>备注</span>&nbsp;:</p>
                        <div class="remarks">{{subTaskProcessInfoList[1].description}}</div>
                        {{else if subTaskState == 3}}
                        <p class="heading"><span>备注</span>&nbsp;:</p>
                        <div class="remarks">{{subTaskProcessInfoList[1].description}}</div>
                        {{/if}}
                    {{/if}}
                </td>
            </tr>
            </tbody>
            {{else}}
            <tbody>
            <tr>
                <td>流程规则异常</td>
            </tr>
            </tbody>
            {{/if}}
        </table>
    </script>
    <!-- 任务流程信息模板 -->
    <script type="text/template" id="processedInfoTpl">
        <dl>
            {{each subTaskProcessInfoList}}
            {{if $value.processName == '施工'}}
            <!-- <dt>Feb 2016</dt> -->
            <dd class="pos-left clearfix">
                <div class="circ"></div>
                <!-- <div class="time">{{$value.updateTime}}</div> -->
                <div class="events">
                    <div class="events-header">
                        <div class="events-headerName">
                            <p>任务名称：{{subTaskName}}，{{$value.processName}}</p>
                            <p>{{$value.updateTime}}</p>
                        </div>
                    </div>
                    <div class="events-body">
                        <div class="row">
                            <div class="events-desc">
                                <div class="txt">
                                    <span>任务状态</span>：
                                    {{if $value.processState == 0}}
                                    未处理
                                    {{else if $value.processState == 1}}
                                    处理完成
                                    {{else if $value.processState == 2}}
                                    未审核
                                    {{else if $value.processState == 3}}
                                    审核驳回
                                    {{else if $value.processState == 4}}
                                    待整改
                                    {{else if $value.processState == 5}}
                                    整改完成
                                    {{else if $value.processState == 6}}
                                    审核通过
                                    {{else if $value.processState == 7}}
                                    已完成
                                    {{/if}}
                                </div>
                                <div class="txt">
                                            <span>{{$value.processName}}人
											{{if $value.uiInputName == ''}}    
                                            </span>：&nbsp;{{$value.operatorName}}
                                    {{else}}
                                    </span>：&nbsp;{{$value.uiInputName}}
                                    {{/if}}
                                </div>
                                <div class="txt"><span>备注</span>：&nbsp;{{$value.description}}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </dd>
            {{else if $value.processName == '审核'}}
            <dd class="pos-right clearfix">
                <div class="circ"></div>
                <!-- <div class="time">{{$value.updateTime}}</div> -->
                <div class="events">
                    <div class="events-header">
                        <div class="events-headerName">
                            <p>任务名称：{{subTaskName}}，{{$value.processName}}</p>
                            <p>{{$value.updateTime}}</p>
                        </div>
                    </div>
                    <div class="events-body">
                        <div class="row">
                            <div class="events-desc">
                                <div class="txt">
                                    <span>任务状态</span>：
                                    <!--{{if $value.processState == 0}}-->
                                    <!--施工中-->
                                    <!--{{else if $value.processState == 1}}-->
                                    <!--审核中-->
                                    <!--{{else if $value.processState == 2}}-->
                                    <!--施工完成-->
                                    <!--{{else if $value.processState == 3}}-->
                                    <!--审核通过-->
                                    <!--{{else if $value.processState == 4}}-->
                                    <!--审核驳回-->
                                    <!--{{/if}}-->
                                    {{if $value.processState == 0}}
                                    未处理
                                    {{else if $value.processState == 1}}
                                    处理完成
                                    {{else if $value.processState == 2}}
                                    未审核
                                    {{else if $value.processState == 3}}
                                    审核驳回
                                    {{else if $value.processState == 4}}
                                    待整改
                                    {{else if $value.processState == 5}}
                                    整改完成
                                    {{else if $value.processState == 6}}
                                    审核通过
                                    {{else if $value.processState == 7}}
                                    已完成
                                    {{/if}}
                                </div>
                                <div class="txt">
                                    <span>{{$value.processName}}人</span>：&nbsp;{{$value.operatorName}}
                                </div>
                                <div class="txt"><span>备注</span>：&nbsp;{{$value.description}}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </dd>
            {{/if}}
            {{/each}}
        </dl>
    </script>
    <script th:src="@{/assets/viewer/viewer.js}"></script>
    <script th:src="@{/assets/jquery.eeyellow.Timeline/jquery.eeyellow.Timeline.js}"></script>
    <script>
        var subTaskId = JSON.parse($.cookie("subTaskCheckId"));
        // 获取子任务数据
        var subTaskData;
        $.ajax({
            url: contextPath + "/subtask/" + subTaskId,
            type: 'GET',
            dataType: "json",
            contentType: "application/json",
            success: function (data) {
                if (data.code == 1) {
                    console.log(data);
                    subTaskData = data.data;
                    var deviceTypeId = data.data.deviceTypeId;
                    var workOrderTypeId = data.data.workOrderTypeId;
                    var projectId = data.data.projectId;

                    // 查询流程规则
                    $.ajax({
                        url: contextPath + "/ProcessRule/queryProcessRuleByDeviceTypeOrderTypeProject",
                        type: 'GET',
                        data: {
                            "deviceTypeId": deviceTypeId,
                            "workOrderTypeId": workOrderTypeId,
                            "projectId": projectId
                        },
                        dataType: 'json',
                        contentType: "application/json",
                        success: function (data) {
                            if (data.code == 1) {
                                console.log(data.data);
                                subTaskData.processRule = data.data;
                                // 图片查看
                                var str = '';
                                for (var i = 0, len = subTaskData.subTaskImageList.length; i < len; i++) {
                                    str += '<li>' +
                                        '<div class="imgs">' +
                                        '<img data-original="' + subTaskData.subTaskImageList[i].imagePath + '" src="' + subTaskData.subTaskImageList[i].imagePath + '" data-id="' + subTaskData.subTaskImageList[i].subImageId + '" alt="' + getImageDescription(subTaskData, i) + '">' +
                                        '<div class="imgDescription" title="'+ getImageDescription(subTaskData, i) +'">' + getImageDescription(subTaskData, i) + '</div>' +
                                        '</div>' +
                                        '</li>';
                                }
                                $("#reviewImagesList").html(str);

                                // 流程信息
                                $("#processedVivaTimeline").html(template('processedInfoTpl', subTaskData));
                                $('.VivaTimeline').vivaTimeline({
                                    carousel: false
                                });

                                $("#basicInformation").html(template('basicInformationTpl', subTaskData));
                                // 审核图片查看
                                $('#reviewImagesList').viewer({
                                    deleteId: false
                                });
                            }
                        },
                        error: function (data) {
                            toastr.error(data.message, "请求失败");
                        }
                    });

                }
            },
            error: function (data) {
                toastr.error(data.message, "请求失败");
            }
        });

        function getImageDescription(subTask, index) {
            var description = '';

            if (subTask != null) {
                if (index < subTask.processRule.processRuleToImageFileList.length) {
                    description = subTask.processRule.processRuleToImageFileList[index].description
                } else {
                    var k = index - subTask.processRule.processRuleToImageFileList.length + 1;
                    description = subTask.deviceId + '_' + k;
                }
            }

            return description;
        }
    </script>
</div>
</body>
</html>